package com.SouthernWall_404.age_tool.common.Network.Packets.S2C.ClientHandler;

import com.SouthernWall_404.age_tool.common.Network.Packets.S2C.MusicBlockNBTS2CPacket;
import com.SouthernWall_404.age_tool.common.world.Entity.MusicBlockEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraftforge.network.NetworkEvent;

import java.util.function.Supplier;

public class MusicBlockNBTClientHandler {

    public static void hanlder(MusicBlockNBTS2CPacket msg, Supplier<NetworkEvent.Context> ctx)
    {
        Level level= Minecraft.getInstance().level;
        BlockEntity blockEntity=level.getBlockEntity(msg.blockPos);
        if(blockEntity!=null&&blockEntity instanceof MusicBlockEntity musicBlockEntity)
        {
            if(msg.modPack!=null)
            {
                musicBlockEntity.setNBT(msg.modPack);
            }
        }
    }
}
